package com.esa.servlet.user;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.esa.dbi.impl.StudentDBImpl;
import com.esa.javabean.Student;

public class UpdateMyInfoServlet extends HttpServlet {
	public void doGet(HttpServletRequest request,HttpServletResponse response)
	throws ServletException,IOException{
		response.setContentType("text/html");
		//response.setCharacterEncoding("utf-8");
		PrintWriter out=response.getWriter();
		this.doPost(request, response);
		out.flush();
		out.close();
	}
	
	public void doPost(HttpServletRequest request,HttpServletResponse response)
	throws ServletException,IOException{
		response.setContentType("text/html");
		PrintWriter out=response.getWriter();
		//System.out.println("UpdateUserServlet line 25.....");
		String sno=request.getParameter("sno");
		String sname=request.getParameter("sname");
		String sex=request.getParameter("sex");
		String insititute=request.getParameter("insititute");
		String acname=request.getParameter("acname");
		
		Student student=new Student();
		student.setSno(sno);
		student.setSname(sname);
		student.setSex(sex);
		student.setInsititute(insititute);
		student.setAcname(acname);
		
		StudentDBImpl sdbi=new StudentDBImpl();
		sdbi.updateStudent(student);
		String acname1=(String)request.getSession().getAttribute("acname");
		request.setAttribute("acname",acname1);
		//System.out.println("UpdateUserServlet line 47....");
		response.sendRedirect("ShowMyInfoServlet");
		out.flush();
		out.close();
		
	}
}
